package com.yishan;


import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * jdk 自带的 httpClient
 *
 * @author: yishan
 * @Date: 2022/6/9 13:55
 **/
public class HttpClientDemo_01 {

    public static void main(String[] args) throws Exception {

        //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        //System.out.println(format.format(new Date()));
        //
        //Calendar calendar = Calendar.getInstance();
        //calendar.setTime(new Date());
        //calendar.add(Calendar.DATE,-1000);
        //Date time = calendar.getTime();
        //System.out.println(format.format(time));

       /* String urlStr = "https://www.baidu.com/";
        URL url = new URL(urlStr);
        URLConnection urlConnection = url.openConnection();
        HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;

        InputStream inputStream = httpURLConnection.getInputStream();
        InputStreamReader isr = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
        BufferedReader br = new BufferedReader(isr);

        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }


*/

        //byte[] code = ("yys" + ":" + "shan012321").getBytes();
        //System.out.println("Basic " + Base64.getEncoder().encodeToString(code));

        //String s = authority("nitp.system", "c5AutNEdbBQE");
        //String s = authority("yys", "shan012321");
        //System.out.println(s);

        //String dateStr = "2022-06-14T23:28:19.000-0700";
        //SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS-SSSS");
        //simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        //
        //Date date = simpleDateFormat.parse(dateStr);
        //System.out.println(date);

        //Date date = dealDateFormat(dateStr);
        //System.out.println(date);
        //System.out.println(new Date());

        Integer a = 12;
        Integer a1 = 12;
        Integer a2 = 129;
        Integer a3 = 129;

        System.out.println(a == a1);
        System.out.println(a3 == a2);

    }

    //public static String authority(String username, String password) {
    //    byte[] code = (username + ":" + password).getBytes();
    //
    //    return "Basic " + Base64.getEncoder().encodeToString(code);
    //}

    public static Date dealDateFormat(String oldDateStr) throws ParseException {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");  //yyyy-MM-dd'T'HH:mm:ss.SSSZ
        Date date = df.parse(oldDateStr);
        SimpleDateFormat df1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
        Date date1 = df1.parse(date.toString());
        DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(df2.format(date1));
    }

}
